package org.zoomdev.zoom.common.caster;

import org.zoomdev.zoom.common.io.Io;
import org.zoomdev.zoom.common.json.JSON;

import java.io.InputStream;
import java.util.Map;

class InputStream2List implements ValueCaster {

    @Override
    public Object to(Object src) {
        InputStream is = (InputStream) src;
        try {
            return JSON.parse(is, Map.class);
        } catch (Exception e) {
            throw new CasterException(e);
        } finally {
            Io.close(is);
        }
    }

}

